package pers.wq.model.bean;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

import pers.wq.model.MajorModel;
import pers.wq.util.TagManager;

public class Student extends BaseBean {
	private int sid;
	private String sname;
	private int gender;
	private Major major;
	private int entry_time;
	private Set<Score> score;
	private Set<SelectMajor> selectMajor;
	private String password;
	private static Map<String,String> genderMap = new HashMap();
	static {
		genderMap.put("1", "男");
		genderMap.put("2", "女");
	}
	public Student() {
		// TODO Auto-generated constructor stub
		System.out.println("Student construct");
	}
	
	@Override
	public Map<String, String> tagMap() {
		// TODO Auto-generated method stub
		Map<String,String> reMap = new LinkedHashMap<String,String>();
		if(getId() != 0){
			reMap.put(TAG_HIDDEN,TagManager.inputHidden("student.id", getId()+""));
		}
		reMap.put("姓名",TagManager.inputText("student.sname", this.getSname()));
		reMap.put("密码",TagManager.inputText("student.password", this.getPassword()));
		reMap.put("性别",TagManager.selectTag("student.gender", "0", genderMap));
		MajorModel mm = new MajorModel();
		Map<String,String> mMap = mm.getAllCollegeMap("mid", "mname");
		String defaultKey = null == major ? null : major.getId() == 0 ? null : String.valueOf(major.getId());
		reMap.put("学院",TagManager.selectTag("student.major.mid", defaultKey, mMap));
		reMap.put("入学年月", TagManager.inputText("student.entry_time",entry_time + ""));
		return reMap;
	}
	
	@Override
	public Map<String, String> tagMap4Stu() {
		// TODO Auto-generated method stub
		System.out.println("Student Bean tagMap4Stu 1");
		Map<String,String> reMap = new LinkedHashMap<String,String>();
		System.out.println("Student Bean tagMap4Stu 2");
		if(getId() != 0){
			System.out.println("Student Bean tagMap4Stu 3");
			reMap.put(TAG_HIDDEN,TagManager.inputHidden("user.id", getId()+""));
		}
		System.out.println("Student Bean tagMap4Stu 4");
		reMap.put("姓名",TagManager.inputTextDisable("user.sname", this.getSname()));
		System.out.println("Student Bean tagMap4Stu 5");
		reMap.put("密码",TagManager.inputTextDisable("user.password", this.getPassword()));
		System.out.println("Student Bean tagMap4Stu 6");
		String g = gender == 1 ? "男":"女";
		System.out.println("Student Bean tagMap4Stu 7");
		reMap.put("性别",TagManager.inputHidden("user.gender",gender+"") + TagManager.inputTextDisable("sg", g));
		System.out.println("Student Bean tagMap4Stu 8");
		String mid = major == null ? "null" : major.getMid() == "null" || major.getMid().equals("0") ? "null" : major.getMid();
		System.out.println("Student Bean tagMap4Stu 9 " + mid);
		reMap.put("学院",TagManager.inputTextDisable("user.major.mid",mid));
		reMap.put("入学年月", TagManager.inputTextDisable("user.entry_time",entry_time + ""));
		System.out.println("Student Bean tagMap4Stu 10");
		return reMap;
	}
	
	@Override
	public void setId(int id) {
		// TODO Auto-generated method stub
		this.sid = id;
	}
	@Override
	public int getId() {
		// TODO Auto-generated method stub
		return this.sid;
	}
	public void setUsername(String username) {
		System.out.println("StudentBean setUsername " + username);
		this.sname = username;
	}
	public String getUsername() {
		return this.sname;
	}
 	public int getSid() {
		return sid;
	}
	public void setSid(int sid) {
		this.sid = sid;
	}
	public String getSname() {
		return sname;
	}
	public void setSname(String sname) {
		this.sname = sname;
	}
	public int getGender() {
		return gender;
	}
	public void setGender(int gender) {
		this.gender = gender;
	}
	public int getEntry_time() {
		return entry_time;
	}
	public void setEntry_time(int entry_time) {
		this.entry_time = entry_time;
	}
	public Set<Score> getScore() {
		return score;
	}
	public void setScore(Set<Score> score) {
		this.score = score;
	}
	public Major getMajor() {
		return major;
	}
	public void setMajor(Major major) {
		this.major = major;
	}
	public Set<SelectMajor> getSelectMajor() {
		return selectMajor;
	}
	public void setSelectMajor(Set<SelectMajor> selectMajor) {
		this.selectMajor = selectMajor;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
}
